import java.awt.Color;

/**
 * The absolute simplest computer player I could think of.
 * It looks at each square, row by row, starting in the upper left.
 * As soon as it finds a valid move, it makes it.  No randomness at all.
 */
public class Clueless implements IPlayer{ 
  protected IBoard _board;
  protected Color _color;

  public void joinBoard(IBoard board, Color color){
    _board = board;
    _color = color;
  }

  public void beginTurn(){
    // No smarts at all.  Grabs the first available valid move.
    for (int r = 0; r < _board.getRowCount(); r++){
      for (int c = 0; c < _board.getColCount(); c++){
        if (_board.isValidMove(getColor(), r, c)){
          // Make the first valid move we can find.
          if (_board.placePiece(this, r, c))
            return;
        }
      }
    }
    // Aparently there are no valid moves, so pass.
    _board.pass(this);
  }

  public void endTurn(){
  }

  public Color getColor(){
    return _color;
  }

  public String getName(){
    return IGui.colorName(_color) + "-Clueless";
  }
} 
